package com.fujitsu.cn.fnst.controller;

import java.text.ParseException;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fujitsu.cn.fnst.base.BaseController;
import com.fujitsu.cn.fnst.service.MeetingBookService;

@Controller
public class BookController extends BaseController {
    @Resource
    private MeetingBookService meetingBookService;
    @RequestMapping(value = "/book", method = RequestMethod.GET)
    public String book(Model model, HttpSession session) {
        if (!isLogin(session)) {
            redirect("/login");
        }
        return "book/book";
    }

    @RequestMapping(value = "/book/time", method = RequestMethod.GET)
    @ResponseBody
    public String timeModel(Model model, HttpSession session, String date,
            String endTime, String beginTime, String amount) {
        if (!isLogin(session)) {
            return "请先登录";
        }
        try {
            return meetingBookService.timeModel(date, beginTime, endTime,
                    amount);
        } catch (ParseException e) {
            return "请输入合法的字符!";
        } finally {

        }

    }
}
